package com.dongdongshop.service.impl;

import com.dongdongshop.mapper.TbAdminMapper;
import com.dongdongshop.pojo.TbAdmin;
import com.dongdongshop.pojo.TbAdminExample;
import com.dongdongshop.pojo.TbUser;
import com.dongdongshop.pojo.TbUserExample;
import com.dongdongshop.service.TbAdminService;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Optional;

@DubboService
@Service
public class TbAdminServiceImpl implements TbAdminService {
    @Autowired
    private TbAdminMapper tbAdminMapper;

    @Override
    public TbAdmin getAdminByPname(String name) {
        TbAdminExample example = new TbAdminExample();
        TbAdminExample.Criteria criteria = example.createCriteria();
        criteria.andNameEqualTo(name);
        List<TbAdmin> tbAdmins = tbAdminMapper.selectByExample(example);
        return tbAdmins.size()>0 ? tbAdmins.get(0):null;
//        return Optional.ofNullable(tbAdmins).map(tbAdmin -> tbAdmin.get(0)).orElse(null);
    }
}
